// components/amount/index.js
import { dumpFunc } from '@src/common/dump'
import { storeBindingsBehavior } from "mobx-miniprogram-bindings";
import base from "@src/store/base";

Component({

  behaviors: [storeBindingsBehavior],
  storeBindings: [
    {
      store: base,
      fields: ['themeColor', 'themeTitleColor']
    },],
  /**
   * 组件的属性列表
   */
  properties: {
    bannerList: {
      type: Array
    },
    login: {
      type: Boolean
    },
    height: {
      type: Number
    },
    from: {
      type:String
    }
  },
  options: {

    addGlobalClass: true
  },

  /**
   * 组件的初始数据
   */
  data: {
    bannerListConfig: {
      indicatorDots: false,
      autoplay: true,
      interval: 4000,
      duration: 500
    },
    swiperCurrent: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    jumpPage(e) {
      let dump = e.currentTarget.dataset.item.dump
      if (!this.data.login && dump.path != "pages/indexChooseCard/main") { this.triggerEvent('login'); return; }
      dumpFunc(dump);
    },
    /**
   * 轮播自动滑动时，获取当前的轮播id
   */
    swiperChange(e) {
      const that = this;
      that.setData({
        swiperCurrent: e.detail.current
      })
    },
    imageChange(e) {
      const that = this;
      that.setData({
        swiperCurrent: e.currentTarget.id
      })
    },
  }
})
